<template>
  <div id="app">
    <ul>
      <li v-for="(n, idx) in arr" :key="idx">
        <span>{{ n }}</span>
        <button @click="del(idx)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1,  5,  3],
    };
  },
  methods: {
    add() {
      const num = Math.floor(Math.random() * 10)
      this.arr.push(num)
    },
    del(idx){
      this.arr.splice(idx, 1)
    }
  }
}
</script>